package com.asset.salesforce.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.asset.salesforce.domain.Employee;
import com.asset.salesforce.domain.JoinRequest;
import com.asset.salesforce.service.JoinRequestService;

@Controller
public class IncludesController {

@Autowired
private JoinRequestService joinRequestService;
	
@RequestMapping(value="/header" ,method=RequestMethod.GET)
public String header(Model model ,HttpSession session){
	Integer joinRequestCount = 0;
	if(null !=session.getAttribute("userDetails") ){
		Employee employee = (Employee)session.getAttribute("userDetails");
		List<JoinRequest> joinRequests  = joinRequestService.getJoinRequestsByOwnerId(employee.getId());
		joinRequestCount = joinRequests.size();
	}
	model.addAttribute("joinRequestCount",joinRequestCount);
	return "header";
}
/////////////////jspf
/*@RequestMapping(value="/footer" ,method=RequestMethod.GET)
public String footer(Model model ,HttpSession session){
	return "footer";
}*/

@RequestMapping(value="/tabs" ,method=RequestMethod.GET)
public String tabs(Model model ,HttpSession session){

	Employee userDetails = (Employee)session.getAttribute("userDetails");
	model.addAttribute("userDetails",userDetails);
	
	return "tabs";
}


/////////////////////////// divide pages test controller
@RequestMapping(value="/container" ,method=RequestMethod.GET)
public String container(Model model ,HttpSession session){
return "container";
}
@RequestMapping(value="/content1" ,method=RequestMethod.GET)
public String content1(Model model ,HttpSession session){
	if(null ==session.getAttribute("userDetails") ){
		return "redirect:/s/login.html";
	}
return "content1";
}
@RequestMapping(value="/testIndex" ,method=RequestMethod.GET)
public String getTestIndex(Model model ,HttpSession session){
	if(null ==session.getAttribute("userDetails") ){
		return "redirect:/s/login.html";
	}
return "testIndex";
}


@RequestMapping(value="/testMovingLists" ,method=RequestMethod.GET)
public String testMovingLists(Model model ,HttpSession session){
	return "testMovingLists";
}

}
